import { routeontheshelves, routeofftheshelves, routedeleted, setdistriofftheshelves, setdistriontheshelves } from "@/utils/method.js"

export default {
  methods: {
    // 提交导游设置
    submitGuide() {
      console.log('提交导游');
    },

    // 上架设置
    putawayPost(id) {
      if (this.detailsData.principal_name) {
        setdistriontheshelves(id).then(() => {
          // console.log(res);
          this.$notification({
            message: '线路上架成功 😊',
            type: 'success'
          })
          this.$router.push({
            name: "DistriCircuit"
          })
        })
          .catch((error) => {
            console.log(error);
            this.$notification.error(error.data.msg)
          });
        // 刷新数据
        // id.status = 2
        // id.status_text = '待上架'
      } else {
        routeontheshelves(id.route_service_id).then(() => {
          this.$message({
            message: '线路上架成功 😊',
            type: 'success'
          })
          this.$router.push({
            name: "CircuitIndex"
          })
        })
          .catch((error) => {
            console.log(error);
            this.$message.error(error.data.msg)
          });
        // 刷新数据
        id.status = 3
        id.status_text = '已上架'
      }

    },
    // 下架设置
    upsoldoutPost(id) {

      if (this.detailsData.principal_name) {
        setdistriofftheshelves(id).then(() => {
          // console.log(res);
          this.$notification({
            message: '线路下架成功 😊',
            type: 'success'
          })
          this.$router.push({
            name: "DistriCircuit"
          })
        })
          .catch((error) => {
            console.log(error);
            this.$notification.error(error.data.msg)
          });
        // 刷新数据
        // id.status = 2
        // id.status_text = '待上架'
      } else {
        routeofftheshelves(id.route_service_id).then(() => {
          // console.log(res);
          this.$message({
            message: '线路下架成功 😊',
            type: 'success'
          })
          this.$router.push({
            name: "CircuitIndex"
          })
        })
          .catch((error) => {
            console.log(error);
            this.$message.error(error.data.msg)
          });
        // 刷新数据
        id.status = 2
        id.status_text = '待上架'
      }
    },
    // 删除设置
    deleteEle(id) {
      routedeleted(id.route_service_id).then(() => {
        this.$message({
          message: '线路删除成功 😊',
          type: 'success'
        })
      })
        .catch((error) => {
          console.log(error);
          this.$message.error(error.data.msg)
        });
    },
  },
}